import type { App } from 'vue';
import { useEnumList  } from '/@/stores/enumList';

export function getEnumSelectorList(enumName:any){
	 var enumStore= useEnumList();
	var newEnumChildren= enumStore.enumList.filter(r=>r.typeName==enumName)[0].children;
	var res= newEnumChildren.map(r=>  {
		return {
			name:r.typeDescribe,
			code:r.typeValue
		};
	});
	return res;
	 //集合中的一列数据
	 // console.log(enumStore.enumList.filter(r=>r.typeName==enumName)[0].children.map(r=>r.typeDescribe));
}

// 常量值转换
export function enumCodeToName(code: any, enumName: any) {
    
	if((code==null||code==''||code==undefined) && code!=0){
		return code;
	}

	const enumStore = useEnumList();
	
	try {
		const enumModel = enumStore.enumList.find(r=>r.typeName==enumName).children.find(r=>r.typeValue == code);
		return enumModel.typeDescribe;
	} catch (error) {
		return code;
	}
}

